<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="handle()">发送请求</button>

    <script>
        function Jsonp(url,callback){
            return new Promise((resolve,reject)=>{
                const script = document.createElement('script')
                window[callback] = function(data){
                    resolve(data)
                }
                script.src =`${url}?cb=${callback}`

                document.body.appendChild(script)
            })
        }




        function handle(){
            Jsonp('http://localhost:3000','callback').then((res)=>{
                console.log(res);
                
            })
        }
    </script>
</body>
</html>